<!doctype html>
<html lang="en">

<head>
	<meta charset="utf-8" />
	<title>光禽脚标机管理系统登陆</title>
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description" />
	<meta content="Coderthemes" name="author" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />

	<!-- App favicon -->
	<link rel="shortcut icon" href="assets/images/favicon.ico">

	<!-- App css -->
	<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
	<link href="assets/css/icons.css" rel="stylesheet" type="text/css" />
	<link href="assets/css/metismenu.min.css" rel="stylesheet" type="text/css" />
	<link href="assets/css/style.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" type="text/css" href="assets/css/custom.css" />

	<script src="assets/js/modernizr.min.js"></script>

</head>

<body>

	<!-- Begin page -->
	<div
		style="height: 500px;width: 400px;border-radius: 4%;padding: 20px; position: absolute;top: 20%; left: 50%;margin-left: -200px;background-color:white;">
		<div>
			<h2 class="text-uppercase text-center pb-2">
				<a href="index.html" class="text-success">
					<span><img src="assets/images/logo.png" alt="" height="40"></span>
				</a>
			</h2>
		</div>

		<div class="p-4">
			<form class="" action="#" role="form">

				<div class="form-group row">
					<div class="col-12">
						<label for="username">账户</label>
						<input class="form-control" type="text" required="" id="username" name="username"
							placeholder="请输入用户名">
					</div>
				</div>
				<div class="form-group row">
					<div class="col-12">
						<label for="password">密码</label>
						<input class="form-control" type="password" required="" id="password" name="password"
							placeholder="请输入密码">
						<a href="recoverpw.html" class="text-muted float-right">忘记密码</a>
					</div>
				</div>

				<div class="form-group row ">
					<div class="col-12">

						<div style="margin-left: 2px;">
							<input id="remember" type="checkbox">
							<label for="remember">记住我</label>
						</div>

					</div>
				</div>

				<div class="form-group row text-center">
					<div class="col-12">
						<button class="btn btn-block  btn-custom" style="width: 100%;" type="submit">登陆</button>
					</div>
				</div>

			</form>

			<div class="row ">
				<div class="col-sm-12 text-center">
					<p class="text-muted">还没有账号密码? <a href="register.html" class="text-dark m-l-5"><b>注册</b></a></p>
				</div>
			</div>

			<div class=" text-center" style="position: absolute;;bottom: 0%;left: 50%;margin-left: -120px;">
				<p>2018 © Highdmin. - Coderthemes.com</p>
			</div>
		</div>
	</div>

	<!-- jQuery  -->
	<script src="assets/js/jquery.min.js"></script>
	<script src="assets/js/bootstrap.bundle.min.js"></script>
	<script src="assets/js/metisMenu.min.js"></script>
	<script src="assets/js/waves.js"></script>
	<script src="assets/js/jquery.slimscroll.js"></script>

	<!-- App js -->
	<script src="assets/js/jquery.core.js"></script>
	<script src="assets/js/jquery.app.js"></script>
	<!-- layer插件 -->
	<script src="plugins/layer2.4/layer.js" type="text/javascript" charset="utf-8"></script>

	<script src="assets/js/custom.js" type="text/javascript" charset="utf-8"></script>

	<!-- 表单验证 -->
	<script src="plugins/jquery.form.js/jquery.form.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="plugins/jquery.validation.1.14.0/jquery.validate.js" type="text/javascript" charset="utf-8"></script>
	<script src="plugins/jquery.validation.1.14.0/validate-methods.js" type="text/javascript" charset="utf-8"></script>
	<script src="plugins/jquery.validation.1.14.0/messages_zh.js" type="text/javascript" charset="utf-8"></script>
	<!-- bootstrap-select -->
	<script src="plugins/bootstrap-select/js/bootstrap-select.js" type="text/javascript" charset="utf-8"></script>

	<script src="plugins/jquery-easyUI/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="plugins/jquery-easyUI/easyui-lang-zh_CN.js" type="text/javascript" charset="utf-8"></script>
	<!-- 星空背景 -->
	<script src="assets/js/background.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$(function () {
			//回显
			var username = getCookie("loginUsername")
			var password = getCookie("loginPassWord")

			if (username != "" && password != "") {
				$("#username").val(username)
				$("#password").val(password)
			}
			$("#username").val(username)

			//表单验证
			$("form").validate({
				rules: {
					username: {
						required: true,
					},
					password: {
						required: true,
					},
				},
				onkeyup: false,
				focusCleanup: true,
				success: "valid",
				submitHandler: function (form) {
					$(form).ajaxSubmit({
						type: "POST",
						url: URL + "loginuser",
						success: function (data) {
							console.log(data)

							if (data.msg == "账户或密码错误") {
								layer.msg(data.msg, {
									icon: 2,
									time: 1000
								});
								return
							}
							let role = data.object.user.role
							// 权限
							let pname = data.object.plateExtendsList.map(item => item.plates.pname)
							// if (data.msg == "用户名或密码为空") {
							// 	parent.layer.msg(data.msg, {
							// 		icon: 2,
							// 		time: 1000
							// 	});
							// 	return
							// }
							layer.msg(data.msg, {
								icon: 1,
								time: 1000
							});
							setCookie("loginUsername", $("#username").val(), "d9")
							setCookie("roleName", role, "d9")
							setCookie("userid", $("#username").val(), "d9")
							sessionStorage.setItem('pname', pname)

							if ($('#remember').is(':checked')) {
								delCookie("loginPassWord")
								setCookie("loginPassWord", $("#password").val(), "d9")
							}
							setCookie("houseId", data.object.houseId, "d9")
							window.location.pathname = '/ShowBarcodeMachine.html'



							// console.log(document.cookie)
						},
						error: function (XMLHttpRequest, textStatus, errorThrown) {
							networkError(XMLHttpRequest, textStatus, errorThrown)
						}
					});
				}
			});
		});
	</script>
</body>

</html>